import request from '@/utils/request'
/**
 * 获取字典列表
 */

export function getSystemDictList(param: any) {
    return request.get('system/dict-data/page', param, { isYuDaoAdmin: true })
}
/**
 * 切换租户

 */
export function switchTenant(data: any) {
    return request.post('system/auth/switch-tenant', data, { isYuDaoAdmin: true })
}
/**
 * 获取用户已绑定租户列表

 */
export function getAccountBindTenantList() {
    return request.get('system/user/getAccountBindTenantList', {}, { isYuDaoAdmin: true })
}
/**
 * 获取验证码
 */
export function getCaptcha() {
    return request.get('captcha', {}, { showErrorMessage: true })
}

/**
 * 获取微信公众号授权码
 */
export function getWechatAuthCode(data: AnyObject) {
    // return request.get('wechat/codeurl', data, { showErrorMessage: false })

    return request.get('member/auth/social-auth-redirect', data, { showErrorMessage: false, isYuDao: true })

}

/**
 * 同步微信信息
 */
export function wechatSync(data: AnyObject) {
    return request.post('wechat/sync', data, { showErrorMessage: false })
}

/**
 * 获取协议信息
 */
export function getAgreementInfo(key: string) {
    return request.get(`agreement/${key}`)
}

/**
 * 重置密码
 */
export function resetPassword(data: AnyObject) {
    // return request.post(`password/reset`, data, { showErrorMessage: true })
    return request.put(`system/user/retrieve-password`, data, { showErrorMessage: true, isYuDaoAdmin: true })

}

/**
 * 发送短信验证码
 */
// export function sendSms(data: AnyObject) {
//     return request.post(`send/mobile/${ data.type }`, data, { showErrorMessage: true })
// }
export function sendSms(data: AnyObject) {
    return request.post(`member/auth/send-sms-code`, data, { showErrorMessage: true, isYuDao: true })
}
/**
 * 未登录发送短信验证码
 */
// export function sendSms(data: AnyObject) {
//     return request.post(`send/mobile/${ data.type }`, data, { showErrorMessage: true })
// }
export function sendAdminSms(data: AnyObject) {
    return request.post(`system/auth/send-sms-code`, data, { showErrorMessage: true, isYuDaoAdmin: true })
}
/**
 * 获取微信jssdk config
 */
export function getWechatSdkConfig(data: AnyObject) {
    return request.get('wechat/jssdkconfig', data, { showErrorMessage: false })
}

/**
 * 上传图片
 */
export function uploadImage(data: AnyObject) {
    // return request.upload('file/image', data, { showErrorMessage: true })
    return request.upload('infra/file/upload', data, { showErrorMessage: true, isYuDao: true })

}

/**
 * 拉取图片
 */
export function fetchImage(data: AnyObject) {
    return request.post('file/image/fetch', data)
}

/**
 * 拉取base64图片
 */
export function fetchBase64Image(data: AnyObject) {
    return request.upload('infra/file/upload', data, { showErrorMessage: true, isYuDao: true })

    // return request.post('file/image/base64', data)
}

/**
 * 获取站点信息
 */
export function getSiteInfo() {
    return request.get('site')
}

/**
 * 获取微信小程序订阅消息模板id
 */
export function getWeappTemplateId(keys: string) {
    return request.get('weapp/subscribemsg', { keys })
}

/**
 * 获取下级地址列表
 * @param pid
 */
export function getAreaListByPid(pid: number = 0) {
    return request.get(`area/list_by_pid/${pid}`)
}

/**
 * 获取地址树列表
 * @param level
 */
export function getAreatree(level: number = 1) {
    return request.get(`area/tree/${level}`)
}

/**
 * 获取地址
 * @param code
 */
export function getAreaByCode(code: number | string) {
    return request.get(`area/code/${code}`)
}

/**
 * 通过经纬度查询地址
 * @param params
 */
export function getAddressByLatlng(params: Record<string, any>) {
    return request.get(`area/address_by_latlng`, params, { showErrorMessage: true })
}

/**
 * 获取海报
 * @returns
 */
export function getPoster(params: Record<string, any>) {
    return request.get("poster", params)
}
export function getPosterTwo(data: Record<string, any>) {
    return request.post("member/social-user/wxa-img", data, { isYuDao: true })
}


/**
 * 获取地图设置
 */
export function getMap() {
    return request.get('map')
}

/**
 * 通过外部交易号获取消息跳转路径
 * @param params
 */
export function getMsgJumpPath(params: Record<string, any>) {
    return request.get('weapp/getMsgJumpPath', params)
}

/**
 * 获取初始化数据信息
 */
export function getInitInfo(params: Record<string, any>) {
    return request.get('init', params)
}